#include "Vector3.h"

Vector3::Vector3()
{

}

Vector3::Vector3(const Vector3& v)
{
	*this = v;
}

float Vector3::x() const
{
	return e[0];
}

float Vector3::y() const
{
	return e[1];
}

float Vector3::z() const
{
	return e[2];
}

float Vector3::operator[](int i) const
{
	if (i > 2) i = 2;
	if (i < 0) i = 0;
	return e[i];
}

float& Vector3::operator[](int i)
{
	if (i > 2) i = 2;
	if (i < 0) i = 0;
	return e[i];
}

void Vector3::setX(float _x)
{
	e[0] = _x;
}

void Vector3::setY(float _y)
{
	e[1] = _y;
}

void Vector3::setZ(float _z)
{
	e[2] = _z;
}

istream& operator>>(istream &is, Vector3 &t)
{
	is >> t.e[0] >> t.e[1] >> t.e[2];
	return is;
}

ostream& operator<<(ostream &os, const Vector3 &t)
{
	os << t.e[0] << ' ' << t.e[1] << ' ' << t.e[2] << ' ';
	return os;
}


//	(v1 * v2) . v3
float tripleProduct(const Vector3 &v1, const Vector3 &v2, const Vector3 &v3)
{
	return dot(cross(v1, v2), v3);
}